package com.lpf.Strategy;

// 测试策略模式
public class StrategyPatternDemo {
    public static void main(String[] args) {
        Context context = new Context();

        // 使用加法策略
        context.setStrategy(new ConcreteStrategyAdd());
        System.out.println("10 + 5 = " + context.executeStrategy(10, 5));

        // 使用减法策略
        context.setStrategy(new ConcreteStrategySubtract());
        System.out.println("10 - 5 = " + context.executeStrategy(10, 5));

        // 使用乘法策略
        context.setStrategy(new ConcreteStrategyMultiply());
        System.out.println("10 * 5 = " + context.executeStrategy(10, 5));
    }
}